
      let ipts = document.querySelectorAll('input');
      console.log(ipts);
      ipts[3].onclick = function (evt) {
        let username = ipts[1].value;
        let password = ipts[2].value;
        console.log(username);
        console.log(password);
        let loginAPI = 'http://jx.xuzhixiang.top/ap/api/login.php';

        let promise = axios.get(loginAPI, {
          params: {username: username,password },
        });
        promise.then((r) => {
          console.log(r.data);
          if (r.data.code == 0) {
            alert(r.data.msg);
          } else {
            alert(r.data.msg);
            console.log(r.data.data.id);
            //存入本地
            localStorage.setItem('id', r.data.data.id);
            localStorage.setItem('username', r.data.data.username);
            //token 登录的凭证、令牌
            localStorage.setItem('token', r.data.data.token);
            //登陆成功跳转首页
            location.href = '../index.html';
          }
        });
        promise.catch(function (err) {
           console.log("失败以后执行");
           console.log(err);
         });
        evt.preventDefault();
      };